home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 September / Ahoy_Magazine_88-09_1988_Double_L.d64 / Cryptic Product (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  943b  |  39 lines

  1. 0 poke53281,0:poke53280,1:print"[147]            cryptic product":print"please wait..."
  2. 1 rem =================================
  3. 2 rem   commodares problem #51-4 :
  4. 3 rem     cryptic product
  5. 4 rem   solution by
  6. 5 rem     justin smalley
  7. 6 rem =================================
  8. 10 a=0:c=2
  9. 15 :
  10. 20 a=a+1:ifa=cthen20
  11. 21 b=-1:ifa>9thenend
  12. 30 b=b+1:ifb=aorb=cthen30
  13. 31 d=0:ifb>9then20
  14. 40 d=d+1:ifd=aord=bord=cthen40
  15. 41 e=-1:ifd>9then30
  16. 50 e=e+1:ife=aore=bore=core=dthen50
  17. 51 ife>9then40
  18. 55 :
  19. 60 p=(a*10+b)*10+c:q=d*10+e:r=p*q
  20. 61 r$=str$(r):iflen(r$)<6then50
  21. 65 :
  22. 70 forn=1to5:y=val(mid$(r$,n+1,1))
  23. 71 ify=aory=bory=cory=dory=ethen50
  24. 73 form=1ton-1:ifm<>nthenify=f(m)then50
  25. 74 next:f(n)=y:next
  26. 75 :
  27. 80 printp;"*";q;"=";r:end
  28. 85 :
  29. 100 rem --- to find all solutions,
  30. 110 rem ***change these lines:
  31. 120 rem 20 a=a+1
  32. 130 rem 30 b=b+1: if b=a then 30
  33. 140 rem 31 c=-1: if b>9 then 20
  34. 150 rem 41 e=-1: if d>9 then 36
  35. 160 rem 80 print p;"*";q;"=";r: goto 50
  36. 170 rem ***add these lines:
  37. 180 rem 36 c=c+1: if c=a or c=b then 36
  38. 190 rem 37 d=0: if c>9 then 30
  39.